import { defineStore } from 'pinia';

import {
  GetRoleListApi,
  GetMenusListApi,
  addMenusApi,
  delMenusApi,
  operationApi,
  errorApi,
} from '/@/api/locality/authority';
import { store } from '/@/store';

interface authorityData {
  roleList: any;
}

export const authorityStore = defineStore({
  id: 'app-authority',
  state: (): authorityData => ({
    roleList: null,
  }),
  getters: {},
  actions: {
    async GetRoleList(params) {
      const data = GetRoleListApi(params);
      return data;
    },
    async GetMenusList(params) {
      const data = GetMenusListApi(params);
      return data;
    },

    async AddMenus(params) {
      const data = addMenusApi(params);
      return data;
    },
    async DelMenus(params) {
      const data = delMenusApi(params);
      return data;
    },
    async Getoperation(params) {
      const data = operationApi(params);
      return data;
    },
    async Geterror(params) {
      const data = errorApi(params);
      return data;
    },
  },
});

export function useUserStoreWithOut() {
  return authorityStore(store);
}
